#----------------------------------------------------------
# Source
#----------------------------------------------------------
set(liblut_INC_DIR ${CMAKE_SOURCE_DIR}/include/liblut)
set(liblut_SRC_DIR ${CMAKE_SOURCE_DIR}/src)

set(liblut_CORE_DIR ${liblut_SRC_DIR}/core)
set(liblut_CORE_INC_DIR ${liblut_INC_DIR}/core)
set(liblut_CORE
                ${liblut_CORE_DIR}/LutBound.cpp
                ${liblut_CORE_DIR}/LutColor.cpp
                ${liblut_CORE_DIR}/color/LutColorRVB8.cpp
                ${liblut_CORE_DIR}/color/LutColorRVB8.h
                ${liblut_CORE_DIR}/color/LutColorHSV32f.cpp
                ${liblut_CORE_DIR}/color/LutColorHSV32f.h
                ${liblut_CORE_DIR}/color/LutColorHSL32f.cpp
                ${liblut_CORE_DIR}/color/LutColorHSL32f.h
                ${liblut_CORE_DIR}/color/LutColorHSL16d88.cpp
                ${liblut_CORE_DIR}/color/LutColorHSL16d88.h
                ${liblut_CORE_DIR}/Interpolator.cpp
                ${liblut_CORE_DIR}/LutModel.cpp
                ${liblut_CORE_DIR}/LutColorSpace.cpp
 )
set(liblut_CORE_INC
                ${liblut_CORE_INC_DIR}/LutBound.h
                ${liblut_CORE_INC_DIR}/LutColor.h
                ${liblut_CORE_INC_DIR}/Interpolator.h
                ${liblut_CORE_INC_DIR}/LutModel.h
                ${liblut_CORE_INC_DIR}/LutColorSpace.h
 )

set(liblut_ALGO_DIR ${liblut_SRC_DIR}/algo)
set(liblut_ALGO_INC_DIR ${liblut_INC_DIR}/algo)
set(liblut_SRC_ALGO
               ${liblut_ALGO_DIR}/convert2img.cpp
)
set(liblut_ALGO_INC
               ${liblut_ALGO_INC_DIR}/convert2img.hpp
)

set(liblut_IO_DIR ${liblut_SRC_DIR}/io)
set(liblut_IO_INC_DIR ${liblut_INC_DIR}/io)
set(liblut_SRC_IO
                ${liblut_IO_DIR}/LutReaderFactory.cpp
                ${liblut_IO_DIR}/LutWriterFactory.cpp
                ${liblut_IO_DIR}/ImgWriter.cpp
)
set(liblut_IO_INC
                ${liblut_IO_INC_DIR}/LutReaderFactory.h
                ${liblut_IO_INC_DIR}/LutWriterFactory.h
                ${liblut_IO_INC_DIR}/LutReader.h
                ${liblut_IO_INC_DIR}/LutWriter.h
                ${liblut_IO_INC_DIR}/ImgWriter.h
)
## IO format
set(liblut_SRC_IO ${liblut_SRC_IO}
                 ${liblut_IO_DIR}/LutIgnXmlFile.h
                 ${liblut_IO_DIR}/LutIgnXmlFile.cpp
                 ${liblut_IO_DIR}/LutQgisXmlFile.h
                 ${liblut_IO_DIR}/LutQgisXmlFile.cpp
                 ${liblut_IO_DIR}/LutVtkXmlFile.h
                 ${liblut_IO_DIR}/LutVtkXmlFile.cpp
)

#----------------------------------------------------------
# core library
#----------------------------------------------------------
include_directories(${CMAKE_SOURCE_DIR}/extern/tinyxml)
set(liblut_LIBRARY_TYPE SHARED)
set(liblut_SRC ${liblut_CORE} ${liblut_SRC_ALGO} ${liblut_SRC_IO} )
set(liblut_INC ${liblut_CORE_INC} ${liblut_ALGO_INC} ${liblut_IO_INC} )

add_library(liblutcore ${liblut_LIBRARY_TYPE} ${liblut_SRC} ${liblut_INC})
set_target_properties(liblutcore PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(liblutcore  luttinyxml ${Boost_LIBRARIES}
   ${TIFF_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES})

#----------------------------------------------------------
# third gui lib
#----------------------------------------------------------

option(BUILD_LUTQT OFF)
if(BUILD_LUTQT)
  set(liblut_SRC_QT
   )
endif(BUILD_LUTQT)

option( BUILD_LUTWX OFF)
if(BUILD_LUTWX)
    find_package(wxWidgets COMPONENTS base core gl aui xrc REQUIRED)
    if(wxWidgets_FOUND)
        message(STATUS "wxWidgets FOUND ")
        include(${wxWidgets_USE_FILE})
    else(wxWidgets_FOUND)
        # For convenience. inform the user
        message(FATAL_ERROR "wxWidgets NOT FOUND ")
    endif(wxWidgets_FOUND)

    if(NOT wxWidgets_wxrc_EXECUTABLE)
       message(FATAL_ERROR " need wxrc for wx icon")
    else(NOT wxWidgets_wxrc_EXECUTABLE)
       set(wxrc_BIN ${wxWidgets_wxrc_EXECUTABLE})
    endif(NOT wxWidgets_wxrc_EXECUTABLE)

    set(liblut_WX_INC_DIR ${liblut_INC_DIR}/gui/wx)
    set(liblut_WX_DIR ${liblut_SRC_DIR}/gui/wx)
    set(rcs_DIR ${CMAKE_SOURCE_DIR}/data/rcs)
    add_custom_command(OUTPUT ${rcs_DIR}/icon_rcs.cpp
                    COMMAND ${wxrc_BIN} ${rcs_DIR}/icon_rcs.xrc -c -o
                            ${rcs_DIR}/icon_rcs.cpp
                    DEPENDS ${rcs_DIR}/icon_rcs.xrc )
    set(liblut_SRC_WX
                ${liblut_WX_DIR}/LutWxPanelView.cpp
                ${liblut_WX_DIR}/ColorDialog.cpp
                ${rcs_DIR}/icon_rcs.cpp
    )
    set(liblut_INC_WX
                ${liblut_WX_INC_DIR}/LutWxPanelView.h
                ${liblut_WX_INC_DIR}/ColorDialog.h
    )

    add_library(liblutwx ${liblut_LIBRARY_TYPE} ${liblut_SRC_WX}
                  ${liblut_INC_WX})
    set_target_properties(liblutwx PROPERTIES LINKER_LANGUAGE CXX)
    target_link_libraries(liblutwx liblutcore luttinyxml ${wxWidgets_LIBRARIES})
endif(BUILD_LUTWX)
